<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>首页-数据录入</title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
		<link href="css/reg_style.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/ljq.css" />
		<link rel="stylesheet" type="text/css" href="css/mui.picker.min.css" />
		<link rel="stylesheet" type="text/css" href="css/common.css"/>
		<link rel="stylesheet" type="text/css" href="css/ljq-post.css"/>
		<style>
			/*背景*/
			
			.beijing {
				width: 100%;
				position: absolute;
				top: 0.55rem;
			}
			
			.beijing .menu {
				width: 90%;
				margin: 0 auto;
				background: #fff;
				border-radius: 5px;
				box-shadow: 1px 1px 1px rgba(65, 152, 255, 0.2);
			}
			
			.beijing .menu span {
				float: left;
				width: 50%;
				text-align: center;
				font-size: 0.15rem;
				margin-top: 0.13rem;
				margin-bottom: 0.13rem;
				color: #808080;
			}
			
			.shuru div {
				height: 0.44rem;
				border-bottom: 1px solid #eee;
				width: 95%;
				margin-left: 5%;
			}
			
			.shuru label {
				float: left;
				width: 25%;
				font-size: 0.14rem;
				color: #4D4D4D;
				margin-top: 0.05rem;
				padding-left: 0;
			}
			input::-webkit-input-placeholder{
			    color: #CCCCCC;
			}
			input::-moz-placeholder{  
			    color: #CCCCCC;     
			}
			input:-ms-input-placeholder{
				color: #CCCCCC;
			}
			.shuru input {
				float: left!important;
				width: 65%!important;
				font-size: 0.14rem!important;
				padding-right: 0;
				color: #808080;
				text-align: right;
				margin-top: 0.05rem;
			}
			
			.shuru em {
				float: right;
				margin-right: 0.12rem;
				font-size: 0.14rem;
				color: #4D4D4D;
				margin-top: 0.13rem;
			}
			
			.yes {
				display: block;
				width: 85%;
				margin: 0 auto;
				text-align: center;
				background: #4198FF;
				height: 0.44rem;
				line-height: 0.44rem;
				font-size: 0.14rem;
				color: #fff;
				margin-top: 1rem;
				border-radius: 5px;
			}
			
			.mui-btn.mui-btn-block.mui-btn-primary {
				//width:90%;
			}
			
			.tupian {
				width: 100%;
				position: fixed;
				top: 0;
				width: 100%;
				z-index: 999;
			}
			
			.lan {
				width: 100%;
				height: 0.8rem;
				background: url(img/beijing.png)no-repeat center center;
			}
			
			.bai {
				width: 100%;
				height: 0.26rem;
				background: #fff;
			}
			/*黄耿升新增*/
			
			[data-type=hour] .mui-dtpicker-title h5,
			[data-type=hour] .mui-picker {
				width: 20%;
			}
			
			[data-type=hour] .mui-dtpicker-title h5:nth-child(4),
			[data-type=hour] .mui-picker:nth-child(4) {
				width: 40%;
			}
		</style>
	</head>

	<body>
		<div class="tupian">
			<div class="lan">
				<div class="head2">
					<em class="mui-action-back"><img class="img1" src="img/fanhui1.png" alt="" /></em>
					<div class="div2"><span class="span3" id="list-shop-lists" onclick="user_select_shop();">数据录入</span></div>
				</div>
			</div>
			<div class="beijing">
				<div class="menu clearfix">
					<span style="border-right: 1px solid #f2f2f2;" class="active5">pos</span>
					<span>收支</span>
				</div>
			</div>
			<div class="bai"></div>
		</div>

		<div class="mui-content">
			<div style="padding-top: 1.05rem;">
				<div class="div_main1">
					<div class="zong">
						<div class="div4 clearfix">
							<span class="span4">录入方式</span>
							<em class="em4" id="index-type-input" onclick="xtype0();">按天</em>
							<input id="index-type-input-id" type="hidden" value="1" />
						</div>
						<div class="div4 clearfix">
							<span class="span4">选择时间</span>
							<em class="em4" id="demo4" style="width: 60%;" data-options='{"type":"date","beginYear":1949,"endYear":3016}'></em>
						</div>
					</div>
					<div class="shuru">
						<div class="mui-input-row clearfix">
							<label>营业额</label>
							<input onkeyup="judge_ver1();" pattern="\d*" type="number" id="index_price" placeholder="营业额保留两位小数">
							<em>元</em>
						</div>
						<div class="mui-input-row clearfix">
							<label>成交笔数</label>
							<input onkeyup="judge_ver1();" pattern="\d*" type="number" id="index_fixture_count" placeholder="请输入大于零的整数">
							<em>笔</em>
						</div>
						<div class="mui-input-row clearfix">
							<label>销售件数</label>
							<input onkeyup="judge_ver1();" pattern="\d*" type="number" id="index_sales_count" placeholder="请输入大于零的整数">
							<em>件</em>
						</div>
						<div class="mui-input-row clearfix">
							<label>产品成本</label>
							<input onkeyup="judge_ver1();" pattern="\d*" type="number" id="index_cost_price" placeholder="产品成本保留两位小数">
							<em>元</em>
						</div>
					</div>
					<button disabled="disabled" onclick="pos_write_input();" id='btn_login1' class="mui-btn mui-btn-block mui-btn-primary yes">确定</button>
				</div>
				<div class="div_main1" style="display: none;">
					<div class="zong">
						<div class="div4 clearfix">
							<span class="span4">选择时间</span>
							<em class="em4" id="demo5" data-options='{"type":"date","beginYear":1949,"endYear":3016}'></em>
						</div>
						<div class="div4 clearfix">
							<span class="span4">费用类别</span>
							<em class="em4" id="index-type-output" onclick="xtype1();">店租</em>
							<input id="index-type-output-id" type="hidden" value="1" />
						</div>
					</div>
					<div class="shuru">
						<div class="mui-input-row clearfix">
							<label>金额</label>
							<input onkeyup="judge_ver2();" pattern="\d*" type="number" id="price" placeholder="金额保留两位小数">
							<em>元</em>
						</div>
						<div class="mui-input-row clearfix">
							<label>事由</label>
							<input onkeyup="judge_ver2();" type="text" id="reason" style="width: 71%!important;" placeholder="请输入支出事由">
						</div>
					</div>
					<button disabled="disabled" onclick="pos_write_output();" id='btn_login2' class="mui-btn mui-btn-block mui-btn-primary yes">确定</button>
				</div>
			</div>
		</div>

		<!--/********************日期控件**************************/-->
		<!--<link rel="stylesheet" type="text/css" href="css/hgs-date.css" />
		<script src="js/hgs-date.js"></script>-->
		<!--/********************日期控件**************************/-->
		<input id="index-shop-lists-id" type="hidden">
		<input id="index-shop-lists" type="hidden">
		<input id='index-end-date' type="hidden" />
		<input id='index-start-date' type="hidden" />

		<!--/***************************************************/-->

		<script src="js/mui.min.js"></script>
		<script src="js/mui.enterfocus.js"></script>
		<script src="js/app.js"></script>
		<!--<script type="text/javascript" src="js/jsencrypt.min.js"></script>
		<script src="js/md5.js"></script>-->
		<script src="js/crypto-js.js"></script>
		<script src="js/jquery.js"></script>
		<script type="text/javascript" src="js/common.js?ver=20180130"></script>
		<script type="text/javascript" src="js/fuction.js?ver=20180130"></script>
		<script src="js/echarts.js"></script>
		<script src="js/mui.picker.min.js"></script>
		<script type="text/javascript">
			mui.init();
		</script>
		<script>
			
			$(document).ready(function () {
			　　$('body').height($('body')[0].clientHeight);
			$('input').focus(function(){
		        $('.tupian').height($('.tupian')[0].clientHeight);
		    })
			});
			/*黄耿升新增*/
			var optionsJsonxs = '{"type":"hour","beginYear":1949,"endYear":3016,"customData":{"h":[';
			optionsJsonxs +='{"value":"0","text":"00:00-01:00"},{"value":"1","text":"01:00-02:00"},{"value":"2","text":"02:00-03:00"},';
			optionsJsonxs +='{"value":"3","text":"03:00-04:00"},{"value":"4","text":"04:00-05:00"},{"value":"5","text":"05:00-06:00"},';
			optionsJsonxs +='{"value":"6","text":"06:00-07:00"},{"value":"7","text":"07:00-08:00"},{"value":"8","text":"08:00-09:00"},';
			optionsJsonxs +='{"value":"9","text":"09:00-10:00"},{"value":"10","text":"10:00-11:00"},{"value":"11","text":"11:00-12:00"},';
			optionsJsonxs +='{"value":"12","text":"12:00-13:00"},{"value":"13","text":"13:00-14:00"},{"value":"14","text":"14:00-15:00"},';
			optionsJsonxs +='{"value":"15","text":"15:00-16:00"},{"value":"16","text":"16:00-17:00"},{"value":"17","text":"17:00-18:00"},';
			optionsJsonxs +='{"value":"18","text":"18:00-19:00"},{"value":"19","text":"19:00-20:00"},{"value":"20","text":"20:00-21:00"},';
			optionsJsonxs +='{"value":"21","text":"21:00-22:00"},{"value":"22","text":"22:00-23:00"},{"value":"23","text":"23:00-24:00"}]';
		optionsJsonxs +='}}';
			var optionsJsonat = '{"type":"date","beginYear":1949,"endYear":3016}';
			//初始化今天日期
			var today=GetDateStr(0);

			$(document).ready(function() {
				$(".menu span").click(function() {
					$(this).addClass("active5").siblings().removeClass("active5");
					$(".div_main1").eq($(this).index()).show().siblings().hide();
				})

			})

			mui.ready(function() {
				//获取当前的客户数据
				xminereadyload();
				//获取当天的日期	
				mui("#demo4")[0].innerHTML = today;
				mui("#demo5")[0].innerHTML = today;
			});

			function xtype0() {
				var picker = new mui.PopPicker();
				var position_json = [{
					value: 1,
					text: '按天'
				}, {
					value: 2,
					text: '按小时'
				}];
				//console.log(position_json);
				picker.setData(position_json);
				picker.show(function(SelectedItem) {
					mui("#index-type-input")[0].innerHTML = SelectedItem[0].text;
					mui("#index-type-input-id")[0].value = SelectedItem[0].value;

					/*黄耿升新增*/
					mui('#demo4')[0].innerHTML = today;
				})
			}

			function xtype1() {
				var picker = new mui.PopPicker();
				var position_json = [{
					value: 1,
					text: '店租'
				}, {
					value: 2,
					text: '薪资'
				}, {
					value: 3,
					text: '采购'
				}, {
					value: 4,
					text: '税费'
				}, {
					value: 5,
					text: '水费'
				}, {
					value: 6,
					text: '电费'
				}, {
					value: 7,
					text: '其它'
				}];
				//console.log(position_json);
				picker.setData(position_json);
				picker.show(function(SelectedItem) {
					mui("#index-type-output")[0].innerHTML = SelectedItem[0].text;
					mui("#index-type-output-id")[0].value = SelectedItem[0].value;
				})
			}

			//判断验证码，是否全部输入
			function judge_ver1() {
				var ver1 = mui('#index_price')[0].value;
				var ver2 = mui('#index_fixture_count')[0].value;
				var ver3 = mui('#index_sales_count')[0].value;
				var ver4 = mui('#index_cost_price')[0].value;
				if(ver1.length >= 1 && ver2.length >= 1 && ver3.length >= 1 && ver4.length >= 1) {
					//console.log("ok1");
					document.getElementById("btn_login1").disabled = false;
					btn_login_se('jianbian3_shengse',"#btn_login1");
				} else {
					//console.log("ok2");
					document.getElementById("btn_login1").disabled = true;
					btn_login_se('jianbian1_qianse',"#btn_login1");
				}
			}

			function judge_ver2() {
				var ver1 = mui('#price')[0].value;
				var ver2 = mui('#reason')[0].value;
				if(ver1.length >= 1 && ver2.length >= 1) {
					//console.log("ok1");
					document.getElementById("btn_login2").disabled = false;
					btn_login_se('jianbian3_shengse',"#btn_login2");
				} else {
					//console.log("ok2");
					document.getElementById("btn_login2").disabled = true;
					btn_login_se('jianbian1_qianse',"#btn_login2");
				}
			}

			// （支出）支出数据录入  请求地址：/pos/write/output
			function pos_write_output() {
				var xbx = {}; //登录后的参数对象AES加密
				xbx.shop_id = user_info.look_shop_id; //是 店铺ID
				xbx.type = mui("#index-type-output-id")[0].value; //是
				xbx.input_time = mui('#demo5')[0].innerHTML;
				xbx.price = parseFloat(mui("#price")[0].value);
				xbx.reason = mui("#reason")[0].value;

				official_login_after(url_host + 'pos/write/output', xbx, 'pos_write_output');

			};

			//pos数据录入----------请求地址：/pos/write/input
			function pos_write_input() {
				var xbx = {}; //登录后的参数对象AES加密
				xbx.shop_id = user_info.look_shop_id; //是 店铺ID
				xbx.type = mui("#index-type-input-id")[0].value; //是 
				xbx.input_time = mui('#demo4')[0].innerHTML;
				xbx.price = parseFloat(mui("#index_price")[0].value); //以前密码
				xbx.fixture_count = parseInt(mui("#index_fixture_count")[0].value); //新密码
				xbx.sales_count = parseInt(mui("#index_sales_count")[0].value); //以前密码
				xbx.cost_price = parseFloat(mui('#index_cost_price')[0].value); //新密码

				official_login_after(url_host + 'pos/write/input', xbx, 'pos_write_input');

			};
		</script>
		<script>
			(function($) {
				$.init();
				var result = $("#demo4")[0];
				var btns = $("#demo4");
				btns.each(function(i, btn) {
					btn.addEventListener('tap', function() {
						var _self = this;
						if(_self.picker) {
							_self.picker.show(function(rs) {
								result.innerText = rs.text;
								_self.picker.dispose();
								_self.picker = null;
							});
						} else {
							var optionsJson = this.getAttribute('data-options') || '{}';

							/*黄耿升新增*/
							if(mui("#index-type-input")[0].innerHTML == '按小时') {
								var optionsJson = optionsJsonxs;
							} else {
								var optionsJson = optionsJsonat;
							}

							var options = JSON.parse(optionsJson);
							var id = this.getAttribute('id');
							/*
							 * 首次显示时实例化组件
							 * 示例为了简洁，将 options 放在了按钮的 dom 上
							 * 也可以直接通过代码声明 optinos 用于实例化 DtPicker
							 */
							_self.picker = new $.DtPicker(options);
							_self.picker.show(function(rs) {

								/*黄耿升新增*/
								if(mui("#index-type-input")[0].innerHTML == '按小时') {
									rs.text = rs.y.text + "-" + rs.m.text + "-" + rs.d.text + " " + rs.h.text;
								} else {
									rs.text = rs.y.text + "-" + rs.m.text + "-" + rs.d.text
								}

								/*
								 * rs.value 拼合后的 value
								 * rs.text 拼合后的 text
								 * rs.y 年，可以通过 rs.y.vaue 和 rs.y.text 获取值和文本
								 * rs.m 月，用法同年
								 * rs.d 日，用法同年
								 * rs.h 时，用法同年
								 * rs.i 分（minutes 的第二个字母），用法同年
								 */
								
								if(rs.text>today){
									mui.toast("不能选择大于今天的日期时间");
									rs.text=today;
								};
								
								result.innerText = rs.text;
								/* 
								 * 返回 false 可以阻止选择框的关闭
								 * return false;
								 */
								/*
								 * 释放组件资源，释放后将将不能再操作组件
								 * 通常情况下，不需要示放组件，new DtPicker(options) 后，可以一直使用。
								 * 当前示例，因为内容较多，如不进行资原释放，在某些设备上会较慢。
								 * 所以每次用完便立即调用 dispose 进行释放，下次用时再创建新实例。
								 */
								_self.picker.dispose();
								_self.picker = null;
							});
						}
					}, false);
				});
			})(mui);

			(function($) {
				$.init();
				var result = $('#demo5')[0];
				var btns = $("#demo5");
				btns.each(function(i, btn) {
					btn.addEventListener('tap', function() {
						var _self = this;
						if(_self.picker) {
							_self.picker.show(function(rs) {
								result.innerText = rs.text;
								_self.picker.dispose();
								_self.picker = null;
							});
						} else {
							var optionsJson = this.getAttribute('data-options') || '{}';
							var options = JSON.parse(optionsJson);
							var id = this.getAttribute('id');
							/*
							 * 首次显示时实例化组件
							 * 示例为了简洁，将 options 放在了按钮的 dom 上
							 * 也可以直接通过代码声明 optinos 用于实例化 DtPicker
							 */
							_self.picker = new $.DtPicker(options);
							_self.picker.show(function(rs) {
								/*
								 * rs.value 拼合后的 value
								 * rs.text 拼合后的 text
								 * rs.y 年，可以通过 rs.y.vaue 和 rs.y.text 获取值和文本
								 * rs.m 月，用法同年
								 * rs.d 日，用法同年
								 * rs.h 时，用法同年
								 * rs.i 分（minutes 的第二个字母），用法同年
								 */
								
								if(rs.text>today){
									mui.toast("不能选择大于今天的日期时间");
									rs.text=today;
								};								
								result.innerText = rs.text;
								/* 
								 * 返回 false 可以阻止选择框的关闭
								 * return false;
								 */
								/*
								 * 释放组件资源，释放后将将不能再操作组件
								 * 通常情况下，不需要示放组件，new DtPicker(options) 后，可以一直使用。
								 * 当前示例，因为内容较多，如不进行资原释放，在某些设备上会较慢。
								 * 所以每次用完便立即调用 dispose 进行释放，下次用时再创建新实例。
								 */
								_self.picker.dispose();
								_self.picker = null;
							});
						}
					}, false);
				});
			})(mui);
		</script>
	</body>

</html>